package com.example.piece.ui.demo

import android.os.Bundle
import android.view.View
import androidx.databinding.ViewDataBinding
import com.therouter.router.Route
import com.example.base.anr.AnrMonitor
import com.example.base.anr.DeadLockMonitor
import com.example.base.anr.DeadLockUtil
import com.example.piece.R
import com.example.piece.constant.RoutePath
import com.example.piece.databinding.TestActivityArnBinding
import com.example.piece.ui.activity.Layer3Activity

/**
 *
 * ANR异常检测
 */

@Route(path =  RoutePath.TESTActivity.ANR_TEST_ACTIVITY)
class ARNTestActivity : Layer3Activity<TestActivityArnBinding,ViewDataBinding>() {
    override val isTransparentStatusBar: Boolean = true
    override val isLockPortrait: Boolean = true
    override val statusBarAlpha: Int = 0
    override val isDarkMode: Boolean = true
    override val isFitsSystemWindows: Boolean = false
    override val leftIcon1Res: Int = R.drawable.ic_back
    override val centerLayoutRes: Int = R.layout.test_activity_arn
    override val title: String
        get() = "ANR异常检测"

    val anrMonitor = AnrMonitor(this.lifecycle)

    val deadLockMonitor = DeadLockMonitor()

    override fun onClickLeftIcon1(view: View) {
        onBackPressed()

    }

    override fun initData(savedInstanceState: Bundle?) {
        super.initData(savedInstanceState)
        DeadLockUtil.createDeadLock()

    }
    /**
     * 监控死锁
     */

    fun onClickDeadlock(view: View) {

        deadLockMonitor.startMonitor()

    }
    /**
     * 卡顿导致ANR
     */

    fun onClickANR(view: View) {
        DeadLockUtil.createDeadLockAnr()

    }


}